// 用户列表 API
export default defineEventHandler(async (event) => {
  return new Promise((resolve, reject) => {
    try {
      // 模拟从数据库获取用户数据
      const users = [
        { id: 1, name: "张三1", email: "zhangsan@example.com", age: 25 },
        { id: 2, name: "李四1", email: "lisi@example.com", age: 30 },
        { id: 3, name: "王五", email: "wangwu@example.com", age: 28 },
        { id: 4, name: "赵六", email: "zhaoliu@example.com", age: 32 },
        { id: 5, name: "钱七", email: "qianqi@example.com", age: 27 },
      ];

      // 返回数据
      setTimeout(() => {
        resolve({
          success: true,
          data: users,
        });
      }, 1000);
    } catch (error) {
      // 错误处理
      throw createError({
        statusCode: 500,
        statusMessage: "获取用户列表失败",
      });
    }
  });
});
